//
//  LabelImageView.m
//  HuaRun2
//
//  Created by admin on 17/9/8.
//  Copyright © 2017年 Sunny. All rights reserved.
//

#import "LabelImageView.h"

@implementation LabelImageView
#pragma mark - life cycle
- (void)dealloc {
    NSLog(@"%@ dealloc", [self class]);
}

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self viewInit];
        [self layoutInit];
    }
    return self;
}

- (void)viewInit {
    //    self.backgroundColor = kRandomColor;
    
    [self addSubview:self.iconView];
    [self addSubview:self.nameLab];

    self.layer.cornerRadius = 5;
    self.layer.borderWidth = 1;
    self.layer.borderColor = RGBA(231, 233, 234, 1).CGColor;
}

- (void)layoutInit {
    weakself(ws);
    
    [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(ws.nameLab.mas_right).offset(kMargin10 / 2);
        make.size.mas_equalTo( CGSizeMake(15, 15));
        make.centerY.mas_equalTo(ws);
        make.right.mas_equalTo(ws).offset(-kMargin10 /2);
    }];
    
    [self.nameLab mas_remakeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(ws).offset(kMargin10);
        make.height.top.mas_equalTo(ws);
    }];
    
    [self mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.mas_equalTo(ws);
        make.height.mas_equalTo(35);
    }];
}


#pragma mark - getter
- (UIImageView *)iconView {
    if (!_iconView) {
        self.iconView = [UIImageView new];
        _iconView.image = [UIImage imageNamed:@"电话001"];
    }
    return _iconView;
}

- (UILabel *)nameLab {
    if (!_nameLab) {
        self.nameLab = [UILabel new];
        _nameLab.textAlignment = NSTextAlignmentLeft;
        _nameLab.font = kGeneralFontSize;
        _nameLab.textColor = [UIColor colorWithHex:@"3c3c3c"];
    }
    return _nameLab;
}
@end
